package org.xtext.runtime.interpreter;

import org.xtext.runtime.term.ITerm;
import org.xtext.runtime.term.List;
import org.xtext.runtime.term.Term;

public class ActionParam<T> {
	T value;
	
	public void set(T value) {
		this.value = value;
	}
	
	public T get() {
		return value;
	}

	@SuppressWarnings("rawtypes")
	public ITerm toLogic() {
		if (java.util.List.class.isInstance(value)) {
			java.util.List list = (java.util.List) value;
			ITerm[] items = new ITerm[list.size()];
			for (int i=0; i<list.size(); i++) {
				items[i] = Term.newInstance(list.get(i));
			}
			return new List(items); 
		}
		return Term.newInstance(value);
	}
}
